package fluxx.draft;

import java.util.LinkedList;
import java.util.List;

public class RuleSet2 {
	// Could be merged with GameState.
	private GameState game;
	private List<Rule> rules = new LinkedList<Rule>();
	public RuleSet2(GameState game) {
		this.game = game; 
	}
	public int getPlayAmount() {
		int playAmount = 1;
		for (Rule rule : rules) {
			playAmount += rule.getPlayAmount(game, playAmount);
		}
		return playAmount;
	}
	public void applyPassTurn() {
		
	}
	// Returns false if _any_ rule says goal is _not_ satisfied
	// TODO Probably awfully wrong.
	public boolean isGoalSatisfied() {
		if (rules.size() == 0) {
			return false;
		}
		for (Rule rule : rules) {
			if (!rule.isGoalSatisfied(game))
				return false;
		}
		return true;
	}
	
	public void addRule(Rule rule) {
		rules.add(rule);
	}

	/*
	Draw amount (applyDrawAmount)
	Play amount (applyPlayAmount)
	Vid turöverlämning (applyPassTurn)
	Vid segerkontroll (applyGoalSatisfied)
	Vid val av kort att spela ut / Innan första kortet spelas (applyChoosePlayedCard / applyPlayFirst)
	*/
	
	public int size() {
		return rules.size();
	}
	public Rule get(int index) {
		return rules.get(index);
	}
	public void remove(Rule rule) {
		rules.remove(rule);
	}
}
